<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('巩固项目')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <input id="childId" name="childId" type="hidden" th:value="*{childId}"/>
        <input id="projectType" name="projectType" type="hidden" th:value="*{projectType}"/>
        <input id="scheduleTime" name="scheduleTime" type="hidden" th:value="*{scheduleTime}"/>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var prefix = ctx + "education/schedule";
    $(function () {
        var options = {
            url: prefix + "/listConsolidate",
            rememberSelected: true,
            pagination: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            queryParams: queryParams,
            columns: [
                {
                    field: 'state',
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false

                },
                {
                    field: 'trainingContent',
                    title: '项目描述',
                    align: "center"
                }]
        };
        $.table.init(options);
    });



    function queryParams(params) {
        var childId = $("#childId").val();
        var projectType = $("#projectType").val();
        var scheduleTime = $("#scheduleTime").val();
        var search = $.table.queryParams(params);
        search.childId = childId;
        search.projectType = projectType;
        search.trainingProgramNumber =scheduleTime;
        return search;
    }


    function submitHandler() {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        if (rows.length > 3) {
            $.modal.alertWarning("最多只能选择3个待巩固项目");
            return;
        }
        var arrayIds = $.table.selectColumns("id");
        var data= $('#bootstrap-table').bootstrapTable('getData',true);
        var selectData = [];
        for(var i = 0;i<arrayIds.length;i++){
            for(var j=0;j<data.length;j++) {
                if(arrayIds[i] == data[j].id) {
                    selectData[i] = data[j];
                }
            }
        }
        parent.renderTable(selectData);
        $.modal.close();
    }

</script>
</body>

</html>